package com.zzx.controller;

import com.zzx.entity.ApiResult;
import com.zzx.entity.TProductOrder;
import com.zzx.service.TProductOrderService;
import com.zzx.utils.OrderIdGeneratorUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "产品单 模块管理")
@RestController
@RequestMapping("/TProductOrder")
public class TProductOrderController {

    @Resource
    private TProductOrderService tProductOrderTypeService;

    @ApiOperation(value = "新增、编辑")
    @PostMapping("/add")
    public ApiResult add(@RequestBody TProductOrder param) {
        tProductOrderTypeService.add(param);
        return ApiResult.ok();
    }

    @ApiOperation(value = "自动生成-生产单号")
    @GetMapping("/generateOrderId")
    public ApiResult generateOrderId() {
        return ApiResult.ok(OrderIdGeneratorUtil.generateOrderId());
    }

    @ApiOperation(value = "删除")
    @PostMapping("/deleteById")
    public ApiResult deleteById(@RequestBody TProductOrder param) {
        tProductOrderTypeService.deleteById(param);
        return ApiResult.ok();
    }

    @ApiOperation(value = "列表查询")
    @PostMapping("/selectBy")
    public ApiResult selectBy(@RequestBody TProductOrder param) {
        return ApiResult.ok(tProductOrderTypeService.selectBy(param));
    }

    @ApiOperation(value = "findById")
    @GetMapping("/findById/{productOrderId}")
    public ApiResult findById(@PathVariable Long productOrderId) {
        return ApiResult.ok(tProductOrderTypeService.findById(productOrderId));
    }

    @ApiOperation(value = "查询用户可提交的产品单-产品列表")
    @PostMapping("/selectSubmitList")
    public ApiResult selectSubmitList(@RequestBody TProductOrder param) {
        return ApiResult.ok(tProductOrderTypeService.selectSubmitList(param));
    }

    @ApiOperation(value = "查询用户可提交的产品单-产品-工序列表")
    @PostMapping("/selectSubmitGXList")
    public ApiResult selectSubmitGXList(@RequestBody TProductOrder param) {
        return ApiResult.ok(tProductOrderTypeService.selectSubmitGXList(param));
    }
}
